﻿using System.Net;
using System.Web.Mvc;

namespace ZSoft.Telegram.UI.Web.Infrastructure.Filters
{
    public class ValidateModelAttribute: ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if(!filterContext.Controller.ViewData.ModelState.IsValid)
            {
                filterContext.Result = new HttpStatusCodeResult(HttpStatusCode.NotAcceptable);
            }

            base.OnActionExecuting(filterContext);
        }
    }
}
